package org.cobertura.test.grammar;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class CatchStatement {
    public void catchStatement(){
        File file=new File("d:\\a.txt");
        FileInputStream fileInputStream= null;
        try {
            fileInputStream = new FileInputStream(file);
            byte bytes[]=new byte[1024];
            int result=-1;
            while((result=fileInputStream.read(bytes))!=-1){
                System.out.println(new String(bytes));
            }
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }finally {
            if(fileInputStream!=null){
                try {
                    fileInputStream.close();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }

    }
}
